import requests
import time
import sys
sys.path.append("../")
from frameworks.utils.RedisUtil import *
from frameworks.cores.LoadClass import *

loader = LoadClass()
redis = RedisUtil()

def aacharts_set_cache(args):
    ck = args["ck"]
    x = args["x"]
    y = args["y"]
    t = args["t"]
    w = args["w"]
    title = args["title"]
    type = args["type"]
    model = args["model"]
    rs = loader.load("controller.ChartsController", "ChartsController", {
        "func": "getOption",
        "data": {"x": x, "y": y, "t": t, "type": type, "title": title, "w": w},
        "model": model,
        "fields": y.split("|")
    })
    redis.vset(ck, rs)


#设置涨跌趋势图
args = {
    "type":"oneline",
    "model":"zs_info_day",
    "x":"count_day",
    "y":"up|equal|down",
    "t":"code",
    "w":"code|000001",
    "ck":"zs_info_day_20241017",
    "title":"涨跌趋势图"
}
aacharts_set_cache(args)
time.sleep(20)

#设置净收入趋势图
args = {
    "type":"moreline",
    "model":"jlr_day",
    "x":"count_day",
    "y":"zhuli",
    "t":"codename",
    "w":"code|000001||code|399001",
    "ck":"jlr_day_20241017",
    "title":"净收入趋势图"
}
aacharts_set_cache(args)
time.sleep(20)


#设置板块净流入趋势图
args = {
    "type":"onebar",
    "model":"money_per_day",
    "x":"codename",
    "y":"flow_money",
    "t":"",
    "w":"count_day|today",
    "ck":"money_per_day_20241017",
    "title":"板块净流入趋势图"
}
aacharts_set_cache(args)
